﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FanaticRock.MediaSource.BilibiliAPI.Helpers
{
    public static class WebPUriHelper
    {
        // http://i2.hdslb.com/bfs/archive/022effa2bbd555cc04569ff537fbd47526eb30a8.jpg@140w_80h_1c.webp
        public static Uri GetWebP(Uri sourceUri, int width, int height)
        {
            var ostr = sourceUri.OriginalString;
            var p1 = ostr.Substring(0, ostr.IndexOf('@'));
            return new Uri($"{p1}@{width}w_{height}h_1c.webp");
        }

        // http://i2.hdslb.com/bfs/archive/022effa2bbd555cc04569ff537fbd47526eb30a8.jpg@140w_80h_1c.webp
        public static Uri GetPng(Uri sourceUri, int width, int height)
        {
            var ostr = sourceUri.OriginalString;
            var p1 = ostr.Substring(0, ostr.IndexOf('@'));
            return new Uri($"{p1}@{width}w_{height}h_1c.png");
        }

        // http://i2.hdslb.com/bfs/archive/022effa2bbd555cc04569ff537fbd47526eb30a8.jpg@140w_80h_1c.webp
        public static Uri GetJpg(Uri sourceUri, int width, int height)
        {
            var ostr = sourceUri.OriginalString;
            var p1 = ostr.Substring(0, ostr.IndexOf('@'));
            return new Uri($"{p1}@{width}w_{height}h_1c.jpg");
        }
    }
}
